
interface s属性 {
    z种类: number,
    s数值: number,
    d大小: number,
    c吃: number,
}

interface bd {
    z种类最大数: number,
    s数值最大数: number,
    //升级进度
    s升级所需得分: number,
    //单个得分
    p碰得分: number,
    c得分: number,
    g杠得分: number,
    //连击设置
    l连击奖励: number,
    l连击时间: number,

    j金币获得: number,
    s升级增加: number,

}

import { _decorator, Animation, BoxCollider2D, Button, Collider2D, Component, Contact2DType, Director, director, ERigidBody2DType, EventTouch, find, instantiate, IPhysics2DContact, log, Node, PhysicsSystem, PhysicsSystem2D, RigidBody2D, size, Tween, tween, UIOpacity, UITransform, v3, Vec2, Vec3 } from 'cc';
import { tongyongTS } from '../tongyongTS/tongyongTS';
import { SJTS } from '../../../jinruchangjing/SJTS';
import { weixinapi } from '../tongyongTS/weixinAIP';

const { ccclass, property } = _decorator;

@ccclass('MJ_xialuoTS')
export class MJ_xialuoTS extends Component {


    ty: tongyongTS

    HC_XLMJ_zuigaofen = 0
    HC_qian = 0
    HC_tilizhi = 10
    HC_ZGguang = 0

    HC_chuci_XLMJ = true

    readonly x下落重力 = 8
    readonly z正常重力 = 1

    readonly b必看广告次数 = 4
    d当前麻将: Node
    g光柱: Node


    K可点击 = true
    K可滑动 = false


    d当前得分 = 0
    d当前进度 = 0

    //竞速模式
    d当前关卡 = 1
    m目标得分 = 80
    m目标达成增加倍率数 = 10


    b变动SJ: bd = {
        z种类最大数: 4,
        s数值最大数: 9,
        //升级进度
        s升级所需得分: 5,
        //单个得分
        p碰得分: 20,
        c得分: 10,
        g杠得分: 20,
        //连击设置
        l连击奖励: 10,
        l连击时间: 5,

        j金币获得: 5,
        s升级增加: 10,

    }



    l连击次数 = 0



    //道具数量
    z炸弹数 = 0
    s刷新数 = 0
    x消除数 = 0
    d抖动数 = 0

    g广告领取炸弹数 = 1
    g广告领取消除数 = 1
    g广告领取抖动数 = 5

    z炸弹距离 = 250

    s节点数组: Node[] = []


    ceshi() {
        this.s升级执行()
    }

    protected onLoad(): void {
        this.ty = find('通用管理').getComponent(tongyongTS)
    }


    start() {
        let c触碰N = find('Canvas/主程序/触碰区域')
        this.g光柱 = find('Canvas/主程序/光柱')
        c触碰N.on(Node.EventType.TOUCH_START, this.点击执行1, this)
        c触碰N.on(Node.EventType.TOUCH_MOVE, this.拖动执行1, this)
        c触碰N.on(Node.EventType.TOUCH_END, this.放开执行1, this)
        c触碰N.on(Node.EventType.TOUCH_CANCEL, this.放开执行1, this)

        this.g更新缓存()
        this.s设置模式()

        this.s生成新的麻将()
        this.K开局动画()

        this.d道具显示更新(5)
        this.g更新金币体力显示(3)

        if (PhysicsSystem2D.instance) {
            PhysicsSystem2D.instance.on(Contact2DType.BEGIN_CONTACT, this.碰撞执行, this);
        }


    }


    j教学步骤 = 0
    j教学执行() {
        this.j教学步骤++
        if (this.j教学步骤 == 1) {
            let jxz = this.ty.find查找('Canvas/教学组')
            jxz.children[0].active = true
        } else if (this.j教学步骤 == 3) {
            let jxz = this.ty.find查找('Canvas/教学组')
            jxz.children[0].active = false
            jxz.children[1].active = true
        } else if (this.j教学步骤 == 5) {
            let jxz = this.ty.find查找('Canvas/教学组')
            jxz.children[1].active = false
            jxz.children[2].active = true
        } else if (this.j教学步骤 == 7) {
            let jxz = this.ty.find查找('Canvas/教学组')
            jxz.children[2].active = false
            jxz.children[3].active = true
        } else if (this.j教学步骤 == 9) {
            let jxz = this.ty.find查找('Canvas/教学组')
            jxz.children[3].active = false

            this.HC_chuci_XLMJ = false
            localStorage.setItem('HC_chuci_XLMJ', JSON.stringify(this.HC_chuci_XLMJ))
        }
    }

    d道具显示更新(num) {
        if (num == 1 || num == 5) {
            if (this.s刷新数 > 0) {
                let n = find("Canvas/主程序/下方显示组/道具组/道具_刷新/fengxiang")
                this.ty.x修改透明度(n, 0)
            }
            let ns = find('Canvas/主程序/下方显示组/道具组/道具_刷新/数量/数量文字')
            this.ty.x修改文字(ns, this.s刷新数 + '')
        }

        if (num == 2 || num == 5) {
            let n = find('Canvas/主程序/下方显示组/道具组/道具_消除/guanggao2')
            if (this.x消除数 > 0) {
                this.ty.x修改透明度(n, 0)
            } else {
                this.ty.x修改透明度(n, 255)
            }
            let nx = find('Canvas/主程序/下方显示组/道具组/道具_消除/数量/数量文字')
            this.ty.x修改文字(nx, this.x消除数 + '')
        }
        if (num == 3 || num == 5) {
            let n = find('Canvas/主程序/下方显示组/道具组/道具_炸弹/guanggao2')
            if (this.z炸弹数 > 0) {
                this.ty.x修改透明度(n, 0)
            } else {
                this.ty.x修改透明度(n, 255)
            }
            let nz = find('Canvas/主程序/下方显示组/道具组/道具_炸弹/数量/数量文字')
            this.ty.x修改文字(nz, this.z炸弹数 + '')

        }
        if (num == 4 || num == 5) {
            let n = find('Canvas/主程序/下方显示组/道具组/道具_抖一抖/guanggao2')
            if (this.d抖动数 > 0) {
                this.ty.x修改透明度(n, 0)
            } else {
                this.ty.x修改透明度(n, 255)
            }
            let nd = find('Canvas/主程序/下方显示组/道具组/道具_抖一抖/数量/数量文字')
            this.ty.x修改文字(nd, this.d抖动数 + '')
        }
    }


    s设置模式() {
        find('Canvas/主程序/上方显示组/竞速模式').active = false
        find('Canvas/主程序/上方显示组/积分模式').active = false
        if (SJTS.j进入模式 == 1) {
            find('Canvas/主程序/上方显示组/积分模式').active = true
            let wzn = find('Canvas/主程序/上方显示组/进度/yuanhuawen/Label')
            let wz = '奖励'
            this.ty.x修改文字(wzn, wz)

            this.b变动SJ =
                this.b变动SJ = JSON.parse((JSON.stringify(SJTS.j积分初始设置)))
        } else {
            find('Canvas/主程序/上方显示组/竞速模式').active = true
            let wzn = find('Canvas/主程序/上方显示组/进度/yuanhuawen/Label')
            let wz = '升级'
            this.ty.x修改文字(wzn, wz)


            this.b变动SJ = JSON.parse((JSON.stringify(SJTS.j竞速初始设置)))
            this.k开始倒计时()
        }


    }

    z没暂停 = true
    s时间 = 0
    jsq: Node
    k开始倒计时() {
        this.s时间 = SJTS.d倒计时间
        let wzn = this.ty.find查找('Canvas/主程序/上方显示组/竞速模式/时间文字')
        this.ty.x修改文字(wzn, this.s时间 + '')

        this.jsq = find('Canvas/主程序/上方显示组/竞速模式')
        let shalou = find('Canvas/主程序/上方显示组/竞速模式/shalou')
        shalou.angle = 8
        let t = tween(shalou).to(0.3, { angle: -8 }).to(0.3, { angle: 8 })
        tween(shalou).repeatForever(t).start()

        let gwz = find('Canvas/主程序/上方显示组/竞速模式/关卡文字')
        let wz = '关卡：' + this.d当前关卡
        this.ty.x修改文字(gwz, wz)

        let mwz = find('Canvas/主程序/上方显示组/竞速模式/目标文字')
        let mdwz = '目标得分：' + this.m目标得分
        this.ty.x修改文字(mwz, mdwz)
    }

    //计时器
    jishi = 0
    protected update(dt: number): void {
        if (SJTS.j进入模式 == 2) {
            if (this.z没暂停) {
                this.jishi += 1 * dt
                if (this.jishi >= 1) {
                    this.jishi = 0
                    this.s时间--
                    if (this.s时间 == 0) {
                        this.s竞速失败执行()
                    }
                    let wzn = this.ty.find查找('Canvas/主程序/上方显示组/竞速模式/时间文字')
                    this.ty.x修改文字(wzn, this.s时间 + '')
                }

            }
        }
    }



    j竞速过关弹出() {
        this.ty.bofangshenyin(32)
        this.z没暂停 = false
        this.m目标得分 += this.m目标达成增加倍率数 * this.d当前关卡
        this.d当前关卡++

        let gwz = find('Canvas/主程序/上方显示组/竞速模式/关卡文字')
        let wz = '关卡：' + this.d当前关卡
        this.ty.x修改文字(gwz, wz)

        if (this.d当前关卡 > this.HC_ZGguang) {  //更新缓存
            localStorage.setItem('HC_ZGguang', JSON.stringify(this.d当前关卡))
        }

        this.s时间 = SJTS.d倒计时间

        this.d当前得分 = 0
        let wzn = find('Canvas/主程序/上方显示组/竞速模式/得分文字')
        wz = '当前得分：' + this.d当前得分
        this.ty.x修改文字(wzn, wz)
        let mwz = find('Canvas/主程序/上方显示组/竞速模式/目标文字')
        let mdwz = '目标得分：' + this.m目标得分
        this.ty.x修改文字(mwz, mdwz)

        this.g更新进度显示()

        gwz = find('Canvas/弹出主/竞速过关弹出/小组/kuanhuawen/目标文字')
        wz = '目标得分：' + this.m目标得分
        this.ty.x修改文字(gwz, wz)
        let ggtn = this.ty.find查找('Canvas/弹出主/竞速过关弹出')
        this.ty.t弹出通用(ggtn)
        let lz = this.ty.find查找('Canvas/弹出主/竞速过关弹出/caidai2')
        this.ty.b播放粒子(lz)


    }

    b必看广告判断次数 = 0
    s随机奖励数组 = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
    j竞速升级弹出奖励() {   //1解锁吃 2解锁杠 3获得道具刷新 4获得道具消除  5获得道具炸弹  6获得道具抖动   7增加连击得分 8增加碰得分 9增加吃得分 10增加杠得分  11获取金币  12增加经验获取度
        let ggtn = this.ty.find查找('Canvas/弹出主/竞速过关弹出')
        this.ty.g关闭通用(ggtn)

        let sz1 = Array.from(this.s随机奖励数组)
        this.ty.s随机打乱(sz1)

        for (let a = 0; a < 200; a++) {
            if (sz1[0] == 3 || sz1[0] == 4 || sz1[0] == 5 || sz1[0] == 6) {
                if (sz1[1] == 3 || sz1[1] == 4 || sz1[1] == 5 || sz1[1] == 6) {
                    this.ty.s随机打乱(sz1)
                } else {
                    break
                }
            } else {
                break
            }
        }
        if (this.b必看广告判断次数 >= this.b必看广告次数) {
            this.b必看广告判断次数 = 0
            sz1[0] = this.ty.Rand(3, 4)
            sz1[1] = this.ty.Rand(5, 6)
        } else {
            this.b必看广告判断次数++
        }


        let tc = this.ty.find查找('Canvas/弹出主/竞速升级弹出')
        let jnz = this.ty.find查找('Canvas/弹出主/竞速升级弹出/技能组').children

        let kuan1 = this.ty.find查找('Canvas/弹出主/竞速升级弹出/小组/框1')
        let kuan2 = this.ty.find查找('Canvas/弹出主/竞速升级弹出/小组/框2')
        if (kuan1.children[1]) {
            kuan1.children[1].destroy()
        }
        if (kuan2.children[1]) {
            kuan2.children[1].destroy()
        }

        let njz1 = instantiate(jnz[sz1[0] - 1])
        njz1.setParent(kuan1)
        njz1.setPosition(0, 30)
        let njz2 = instantiate(jnz[sz1[1] - 1])
        njz2.setParent(kuan2)
        njz2.setPosition(0, 30)

        let xk1 = this.ty.find查找('Canvas/弹出主/竞速升级弹出/小组/框1')
        let xk2 = this.ty.find查找('Canvas/弹出主/竞速升级弹出/小组/框2')
        this.ty.x修改Button参数(xk1, sz1[0] + '')
        this.ty.x修改Button参数(xk2, sz1[1] + '')
        //动画
        this.ty.t弹出通用(tc)



    }

    s升级选择点击(e: EventTouch, env) {//1解锁吃 2解锁杠 3获得道具刷新 4获得道具消除  5获得道具炸弹  6获得道具抖动   7增加连击得分 8增加碰得分 9增加吃得分 10增加杠得分  11获取金币  12增加经验获取度
        this.ty.g关闭banner()
        this.ty.bofangshenyin(1)

        let n: Node = e.target
        tween(n).to(0.2, { scale: v3(1.2, 1.2, 1) }).to(0.5, { scale: v3(1, 1, 1) }).to(0.2, { scale: v3(-1, 1, 1) }).to(0.2, { scale: v3(1, 1, 1) })
            .call(() => {
                this.z没暂停 = true
                let tn = this.ty.find查找('Canvas/弹出主/竞速升级弹出')
                this.ty.g关闭通用(tn)
            }).start()




        if (env == 3) {
            this.s刷新数 += 5
            this.d道具显示更新(1)
        }
        if (env == 4) {
            this.x消除数 += 1
            this.d道具显示更新(2)

        }
        if (env == 5) {
            this.z炸弹数 += 1
            this.d道具显示更新(3)

        }
        if (env == 6) {
            this.d抖动数 += 5
            this.d道具显示更新(4)
        }

        if (env == 7) {
            this.b变动SJ.l连击奖励 += 20
        }
        if (env == 8) {
            this.b变动SJ.p碰得分 += 20
        }
        if (env == 9) {
            this.b变动SJ.c得分 += 10
        }
        if (env == 10) {
            this.b变动SJ.g杠得分 += 40
        }
        if (env == 11) {
            this.ty.bofangshenyin(33)
            this.ty.g关闭通用(find('Canvas/弹出主/金币奖励弹出'))
            let lz = this.ty.find查找('Canvas/主程序/动画组/掉金币')
            this.ty.b播放粒子(lz)
            this.scheduleOnce(() => {
                this.HC_qian += 500
                this.g更新金币体力显示(1)
                localStorage.setItem('HC_qian', JSON.stringify(this.HC_qian))
            }, 0.8)
        }
        if (env == 12) {
            let df = this.m目标得分 / 2
            this.d当前得分 = df
            this.g更新得分显示()
            this.g更新进度显示()
        }


    }

    f时间复活次数 = 1
    s竞速失败执行() {
        let nnf1 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮1组/按钮_复活满格')
        let nnf2 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮1组/按钮_复活时间')
        nnf2.setPosition(140, -200)
        nnf1.setPosition(140, 5000)
        this.z没暂停 = false
        let wznn = this.ty.find查找("Canvas/弹出主/满格失败/小组/lab")
        this.ty.c持续缩放(wznn)
        let wzw = '时间不足了'
        this.ty.x修改文字(wznn, wzw)

        this.ty.bofangshenyin(12)
        let xn = this.ty.find查找("Canvas/弹出主/满格失败/小组/款背景/xinsui")
        this.ty.c持续旋转(xn, 8, 0.3)

        let n = find('Canvas/弹出主/满格失败')
        this.ty.t弹出通用(n)


        let dfn = this.ty.find查找('Canvas/弹出主/满格失败/小组/得分文字')
        let wz = '当前关卡：' + this.d当前关卡
        this.ty.x修改文字(dfn, wz)

        if (this.f时间复活次数 > 0) {
            let tsn = this.ty.find查找('Canvas/弹出主/满格失败/小组/huawen1/提示文字')
            let wz = '复活（仅一次机会）'
            this.ty.x修改文字(tsn, wz)

            let nan1 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮1组')
            let nan2 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮2组')
            nan2.setPosition(0, 5000)
            nan1.setPosition(0, 0)
        } else {
            let tsn = this.ty.find查找('Canvas/弹出主/满格失败/小组/huawen1/提示文字')
            let wz = '胜败乃兵家常事！'
            this.ty.x修改文字(tsn, wz)

            let nan1 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮1组')
            let nan2 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮2组')

            nan1.setPosition(0, 5000)
            nan2.setPosition(0, 0)
        }

    }


    f满格复活次数 = 1
    s满格失败执行() {
        let nnf1 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮1组/按钮_复活满格')
        let nnf2 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮1组/按钮_复活时间')
        nnf1.setPosition(140, -200)
        nnf2.setPosition(140, 5000)

        let wznn = this.ty.find查找("Canvas/弹出主/满格失败/小组/lab")
        this.ty.c持续缩放(wznn)
        let wzw = '没有位置了'
        this.ty.x修改文字(wznn, wzw)
        this.ty.bofangshenyin(12)
        let xn = this.ty.find查找("Canvas/弹出主/满格失败/小组/款背景/xinsui")
        this.ty.c持续旋转(xn, 8, 0.3)

        let n = find('Canvas/弹出主/满格失败')
        this.ty.t弹出通用(n)

        if (SJTS.j进入模式 == 1) {
            let dfn = this.ty.find查找('Canvas/弹出主/满格失败/小组/得分文字')
            let wz = '当前得分：' + this.d当前得分
            this.ty.x修改文字(dfn, wz)

            if (this.f满格复活次数 > 0) {
                let tsn = this.ty.find查找('Canvas/弹出主/满格失败/小组/huawen1/提示文字')
                let wz = '复活（仅一次机会）'
                this.ty.x修改文字(tsn, wz)

                let nan1 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮1组')
                let nan2 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮2组')
                nan2.setPosition(0, 5000)
                nan1.setPosition(0, 0)
            } else {
                let tsn = this.ty.find查找('Canvas/弹出主/满格失败/小组/huawen1/提示文字')
                let wz = '胜败乃兵家常事！'
                this.ty.x修改文字(tsn, wz)

                let nan1 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮1组')
                let nan2 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮2组')

                nan1.setPosition(0, 5000)
                nan2.setPosition(0, 0)
            }

        } else {
            this.z没暂停 = false
            let dfn = this.ty.find查找('Canvas/弹出主/满格失败/小组/得分文字')
            let wz = '当前关卡：' + this.d当前关卡
            this.ty.x修改文字(dfn, wz)

            if (this.f满格复活次数 > 0) {
                let tsn = this.ty.find查找('Canvas/弹出主/满格失败/小组/huawen1/提示文字')
                let wz = '复活（仅一次机会）'
                this.ty.x修改文字(tsn, wz)

                let nan1 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮1组')
                let nan2 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮2组')
                nan2.setPosition(0, 5000)
                nan1.setPosition(0, 0)
            } else {
                let tsn = this.ty.find查找('Canvas/弹出主/满格失败/小组/huawen1/提示文字')
                let wz = '胜败乃兵家常事！'
                this.ty.x修改文字(tsn, wz)

                let nan1 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮1组')
                let nan2 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮2组')

                nan1.setPosition(0, 5000)
                nan2.setPosition(0, 0)
            }
        }
    }

    放弃复活() {
        this.ty.bofangshenyin(1)
        let nan1 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮1组')
        let nan2 = this.ty.find查找('Canvas/弹出主/满格失败/小组/按钮2组')

        let tsn = this.ty.find查找('Canvas/弹出主/满格失败/小组/huawen1/提示文字')
        let wz = '胜败乃兵家常事！'
        this.ty.x修改文字(tsn, wz)
        nan1.setPosition(0, 5000)
        nan2.setPosition(0, 0)
    }


    f满格复活() {
        let f = () => {
            this.z没暂停 = true
            let n = find('Canvas/弹出主/满格失败')
            this.ty.g关闭通用(n)
            this.f满格复活次数 = 0

            let a: Node[] = []
            this.s节点数组.forEach((n: Node) => {
                a.push(n)
            })
            a.forEach((n: Node) => {
                if (n != this.d当前麻将) {
                    if (n.position.y >= -100) {
                        this.s节点数组.splice(this.s节点数组.indexOf(n), 1)
                        n.destroy()
                    }
                }
            })
        }
        this.ty.c创建激励广告(f)

    }

    f时间复活() {
        let f = () => {
            let n = find('Canvas/弹出主/满格失败')
            this.ty.g关闭通用(n)
            this.f时间复活次数 = 0

            this.s时间 = SJTS.d倒计时间
            this.z没暂停 = true
        }
        this.ty.c创建激励广告(f)

    }

    j警告线() {
        let n = this.ty.find查找('Canvas/主程序/动画组/警告线')
        this.ty.x修改透明度(n, 0)
        Tween.stopAllByTarget(n)
        let t = tween(n.getComponent(UIOpacity)).to(0.2, { opacity: 255 }).to(0.2, { opacity: 0 })
        tween(n.getComponent(UIOpacity)).repeat(3, t).start()
    }


    K开局动画() {
        //光环转动
        let n = find('Canvas/主程序/上方显示组/进度/guanghuan')
        let t = tween(n).by(5, { angle: 360 })
        tween(n).repeatForever(t).start()


    }

    g更新缓存() {
        function jilu(lab: string, n) {
            let a = localStorage.getItem(lab)
            if (a == null || a == '') { localStorage.setItem(lab, JSON.stringify(n)); }
        }
        jilu('HC_XLMJ_zuigaofen', this.HC_XLMJ_zuigaofen)
        jilu('HC_ZGguang', this.HC_ZGguang)
        jilu('HC_qian', this.HC_qian)
        jilu('HC_doudongshu', this.d抖动数)
        jilu('HC_tilizhi', this.HC_tilizhi)
        jilu('HC_chuci_XLMJ', this.HC_chuci_XLMJ)



        this.HC_XLMJ_zuigaofen = JSON.parse(localStorage.getItem('HC_XLMJ_zuigaofen'))
        this.HC_ZGguang = JSON.parse(localStorage.getItem('HC_ZGguang'))
        this.HC_qian = JSON.parse(localStorage.getItem('HC_qian'))
        if (SJTS.j进入模式 == 1) {
            this.d抖动数 = JSON.parse(localStorage.getItem('HC_doudongshu'))
        }
        this.HC_tilizhi = JSON.parse(localStorage.getItem('HC_tilizhi'))
        this.HC_chuci_XLMJ = JSON.parse(localStorage.getItem('HC_chuci_XLMJ'))

        let wzn = find('Canvas/主程序/上方显示组/积分模式/得分显示/历史最高分文字')
        let wz = this.HC_XLMJ_zuigaofen + ''
        this.ty.x修改文字(wzn, wz)


    }

    g更新金币体力显示(num: number) {
        if (num == 1 || num == 3) {
            let wzn = find('Canvas/主程序/上方显示组/金币体力显示/金币数值文字')
            let wz = this.HC_qian + ''
            this.ty.x修改文字(wzn, wz)
        }
        if (num == 2 || num == 3) {
            let wzn = find('Canvas/主程序/上方显示组/金币体力显示/体力数值文字')
            let wz = this.HC_tilizhi + ''
            this.ty.x修改文字(wzn, wz)
        }
    }


    updateGold(gold: number) {
        let wzn = find('Canvas/主程序/上方显示组/金币体力显示/金币数值文字')
        this.ty.x修改文字(wzn, String(gold));
    }


    g更新进度显示() {
        let jst = find('Canvas/主程序/上方显示组/进度/底板/遮罩/jdt')
        let shaizi = find('Canvas/主程序/上方显示组/进度/底板/筛子位置/sz')
        let x = -350
        if (SJTS.j进入模式 == 1) {
            x = -350 + (this.d当前进度 / this.b变动SJ.s升级所需得分 * 700)
        } else {
            x = -350 + (this.d当前得分 / this.m目标得分 * 700)
        }



        let shengjile = false
        if (x >= 350) {
            x = 350
            shengjile = true
        }

        tween(jst).to(0.3, { position: v3(x, 0) }).start()
        tween(shaizi).to(0.3, { position: v3(x, 0) })
            .call(() => {
                if (shengjile) {
                    this.d当前进度 = 0
                    this.s升级执行()
                }
            })
            .start()
    }

    g更新得分显示() {
        if (SJTS.j进入模式 == 1) {
            let wzn = find('Canvas/主程序/上方显示组/积分模式/得分显示/当前分文字')
            let wz = this.d当前得分 + ''
            this.ty.x修改文字(wzn, wz)
        } else {
            let wzn = find('Canvas/主程序/上方显示组/竞速模式/得分文字')
            let wz = '当前得分：' + this.d当前得分
            this.ty.x修改文字(wzn, wz)

        }


    }

    s升级执行() {
        this.ty.bofangshenyin(32)

        let jst = find('Canvas/主程序/上方显示组/进度/底板/遮罩/jdt')
        let shaizi = find('Canvas/主程序/上方显示组/进度/底板/筛子位置/sz')
        let y = jst.position.y
        jst.setPosition(-350, y)
        y = shaizi.position.y
        shaizi.setPosition(-350, y)

        this.t提升难度()

        if (SJTS.j进入模式 == 1) {
            this.b变动SJ.s升级所需得分 += 2
            this.b变动SJ.j金币获得 += this.b变动SJ.s升级增加
            this.奖励金币动画与执行()
        } else {
            this.j竞速过关弹出()
        }
    }

    t提升难度() {
        this.ty.z震动执行()
        if (this.b变动SJ.s数值最大数 > 5) {
            if (this.b变动SJ.z种类最大数 < 4) {
                this.b变动SJ.z种类最大数++
                this.b变动SJ.s数值最大数--
            }
        }

        if (this.b变动SJ.s数值最大数 < 9) {
            this.b变动SJ.s数值最大数++
        }


    }

    b倍率 = 1
    奖励金币动画与执行() {
        this.ty.c创建banner(2)
        let li = find('Canvas/弹出主/金币奖励弹出/caidai2')
        this.ty.b播放粒子(li)

        let n = find('Canvas/弹出主/金币奖励弹出')
        let jbs = this.b变动SJ.j金币获得
        let wzn = find('Canvas/弹出主/金币奖励弹出/小组/jingbi普通/数量文字')
        this.ty.x修改文字(wzn, 'x' + jbs)

        let shaizi = find('Canvas/弹出主/金币奖励弹出/小组/shaizixiao')
        Tween.stopAllByTarget(shaizi)
        shaizi.setPosition(-200, 40)
        let t = tween(shaizi).to(0.6, { position: v3(200, 40) }).to(0.6, { position: v3(-200, 40) })
        tween(shaizi).repeatForever(t).start()
        let dnz = find('Canvas/弹出主/金币奖励弹出/小组/jingbi多倍/数量文字')
        let f = () => {
            this.ty.x修改文字(dnz, "x" + jbs * this.b倍率)
        }
        let t2 = tween(dnz)
            .call(() => {
                this.b倍率 = 2
                f()
            })
            .delay(0.1)
            .call(() => {
                this.b倍率 = 3
                f()
            })
            .delay(0.1)
            .call(() => {
                this.b倍率 = 4
                f()
            })
            .delay(0.1)
            .call(() => {
                this.b倍率 = 5
                f()
            })
            .delay(0.1)
            .call(() => {
                this.b倍率 = 4
                f()
            })
            .delay(0.1)
            .call(() => {
                this.b倍率 = 3
                f()
            })
            .delay(0.1)
            .call(() => {
                this.b倍率 = 2
                f()
            })

        Tween.stopAllByTarget(dnz)
        tween(dnz).repeatForever(t2).start()
        this.ty.t弹出通用(n)
    }

    P普通领取() {
        this.ty.g关闭banner()
        this.ty.bofangshenyin(1)
        let djb = find('Canvas/主程序/动画组/金币')
        djb.setWorldPosition(find('Canvas/弹出主/金币奖励弹出/小组/jingbi普通').worldPosition)
        tween(djb).to(0.8, { worldPosition: find('Canvas/主程序/上方显示组/金币体力显示/jingbi').worldPosition }).start()
        this.ty.g关闭通用(find('Canvas/弹出主/金币奖励弹出'))
        this.scheduleOnce(() => {
            this.HC_qian += this.b变动SJ.j金币获得
            this.g更新金币体力显示(1)
            localStorage.setItem('HC_qian', JSON.stringify(this.HC_qian))
        }, 0.8)
    }


    d多倍领取() {
        this.ty.g关闭banner()
        let f = () => {
            this.ty.bofangshenyin(33)
            let lz = this.ty.find查找('Canvas/主程序/动画组/掉金币')
            this.ty.b播放粒子(lz)
            this.ty.g关闭通用(find('Canvas/弹出主/金币奖励弹出'))
            this.scheduleOnce(() => {
                this.HC_qian += this.b变动SJ.j金币获得 * this.b倍率
                this.g更新金币体力显示(1)
                localStorage.setItem('HC_qian', JSON.stringify(this.HC_qian))
            }, 0.8)
        }
        this.ty.c创建激励广告(f)

    }


    n难度突增次数 = 0
    readonly n难度突增判断次数 = 6
    s生成新的麻将() {
        if (this.HC_chuci_XLMJ) {
            this.j教学执行()
        }

        this.k可碰撞 = true
        this.g光柱.setPosition(0, -89)
        let n = find('Canvas/克隆组/牌1')
        let fn = instantiate(n)
        //设置类型


        let z种类s = this.ty.Rand(1, this.b变动SJ.z种类最大数)
        let s数值s = 0
        if (z种类s != 4) {
            s数值s = this.ty.Rand(1, this.b变动SJ.s数值最大数)
        } else {
            s数值s = this.ty.Rand(1, 7)
        }

        this.n难度突增次数++
        if (this.n难度突增次数 >= this.n难度突增判断次数) {
            this.n难度突增次数 = 0

            z种类s = this.ty.Rand(3, 4)
            s数值s = 0
            if (z种类s != 4) {
                s数值s = this.ty.Rand(5, 9)
            } else {
                s数值s = this.ty.Rand(1, 7)
            }
        }

        let d大小s = 1
        let a: s属性 = {
            z种类: z种类s,
            s数值: s数值s,
            d大小: d大小s,
            c吃: 0
        }
        fn.name = JSON.stringify(a)

        fn.children[0].children[z种类s - 1].children[s数值s - 1].active = true
        //设置位置
        fn.setPosition(0, 420)
        fn.setParent(find('Canvas/主程序/碰撞主'))
        this.d当前麻将 = fn
        this.s节点数组.push(fn)
        let collider = fn.getComponent(Collider2D);
        collider.enabled = false

        let rig = fn.getComponent(RigidBody2D)
        rig.gravityScale = this.x下落重力
    }

    s生成合成麻将(sx: s属性, v: Vec3, ang, c吃?: number) {
        director.once(Director.EVENT_AFTER_PHYSICS, () => {    //EVENT_AFTER_PHYSICS为物理碰撞完成后执行的事件
            let f = () => {
                this.ty.bofangshenyin(15)
                let n = find('Canvas/克隆组/牌2')
                let fn = instantiate(n)
                //设置类型
                let z种类s = sx.z种类
                let s数值s = sx.s数值
                let d大小s = 2
                let chi = 0
                if (c吃) {
                    chi = c吃
                    let sz = [s数值s, chi]
                    sz.sort((a, b) => a - b)
                    s数值s = sz[0]
                    chi = sz[1]
                }
                let a: s属性 = {
                    z种类: z种类s,
                    s数值: s数值s,
                    d大小: d大小s,
                    c吃: chi
                }

                fn.name = JSON.stringify(a)
                if (c吃) {
                    fn.children[0].children[0].children[z种类s - 1].children[s数值s - 1].active = true
                    fn.children[0].children[1].children[z种类s - 1].children[chi - 1].active = true
                } else {
                    fn.children[0].children[0].children[z种类s - 1].children[s数值s - 1].active = true
                    fn.children[0].children[1].children[z种类s - 1].children[s数值s - 1].active = true
                }

                let rig = fn.getComponent(RigidBody2D)
                rig.gravityScale = this.z正常重力
                //设置位置
                fn.setParent(find('Canvas/主程序/碰撞主'))
                fn.setWorldPosition(v)

                this.s节点数组.push(fn)

                fn.angle = ang
                fn.scale = v3(0.1, 0.1, 1)

                tween(fn).to(0.3, { scale: v3(1, 1, 1) })
                    .call(() => {
                        let collider = fn.getComponent(BoxCollider2D);
                        collider.tag = 0
                    })
                    .start()
            }
            this.scheduleOnce(f, 0.1)
        }, this)

    }

    k可放开 = false
    点击执行1(e: EventTouch) {
        if (this.K可点击) {
            this.k可放开 = true
            this.K可滑动 = true
            let lizi = find('Canvas/主程序/动画组/点击粒子')

            let v = this.ty.d点击移动位置(e)
            lizi.setPosition(v)
            this.ty.b播放粒子(lizi)
            if (this.d当前麻将) {
                if (v.x > -314 && v.x < 314) {
                    this.d当前麻将.setPosition(v.x, 420)
                    this.g光柱.setPosition(v.x, -89)
                } else if (v.x < -314) {
                    this.d当前麻将.setPosition(-314, 420)
                    this.g光柱.setPosition(-314, -89)
                } else if (v.x > 314) {
                    this.d当前麻将.setPosition(314, 420)
                    this.g光柱.setPosition(314, -89)
                }
            }
        }

    }


    拖动执行1(e: EventTouch) {
        if (this.K可滑动) {
            let v2 = new Vec2
            e.getUILocation(v2)
            let v3 = new Vec3(v2.x, v2.y, 0)
            let v = new Vec3(0, 0, 0)
            this.node.getComponent(UITransform).convertToNodeSpaceAR(v3, v)     //转换坐标
            if (this.d当前麻将) {
                if (v.x > -314 && v.x < 314) {
                    this.d当前麻将.setPosition(v.x, 420)
                    this.g光柱.setPosition(v.x, -89)
                }
            }
        }
    }

    放开执行1(e: EventTouch) {
        if (this.k可放开) {
            this.ty.bofangshenyin(24)
            this.K可点击 = false
            this.K可滑动 = false
            this.k可放开 = false
            this.g光柱.setPosition(2000, -89)
            this.d当前麻将.getComponent(RigidBody2D).type = ERigidBody2DType.Dynamic
            let collider = this.d当前麻将.getComponent(BoxCollider2D);
            collider.enabled = true
            collider.tag = 0
            collider.once(Contact2DType.BEGIN_CONTACT, this.s碰撞生成检测, this);// 只在两个碰撞体开始接触时被调用一次    

        }

    }

    k可碰撞 = true
    碰撞执行(self: Collider2D, other: Collider2D, contact: IPhysics2DContact,) {
        if (this.k可碰撞) {
            if (other.node.getComponent(BoxCollider2D).tag != -1 && self.node.getComponent(BoxCollider2D).tag != -1) {//排除地板和刚刚生成的
                let othersx: s属性 = JSON.parse(other.node.name)
                let selfsx: s属性 = JSON.parse(self.node.name)

                if (othersx.s数值 == selfsx.s数值 && othersx.z种类 == selfsx.z种类 && othersx.d大小 == 1 && selfsx.d大小 == 1) {   //两小合成双
                    this.k可碰撞 = false
                    let sen = self.node
                    let otn = other.node
                    self.off(Contact2DType.BEGIN_CONTACT, this.碰撞执行, this)
                    other.off(Contact2DType.BEGIN_CONTACT, this.碰撞执行, this)

                    let sv = sen.worldPosition
                    let ov = otn.worldPosition
                    let v = v3((sv.x + ov.x) / 2, (sv.y + ov.y) / 2, 0)

                    let ang = this.ty.j夹角计算(sv, ov)
                    this.s生成合成麻将(selfsx, v, ang)
                    this.s节点数组.splice(this.s节点数组.indexOf(otn), 1)
                    this.s节点数组.splice(this.s节点数组.indexOf(sen), 1)
                    director.once(Director.EVENT_AFTER_PHYSICS, () => {    //EVENT_AFTER_PHYSICS为物理碰撞完成后执行的事件
                        otn.destroy()
                        sen.destroy()
                        this.k可碰撞 = true
                    }, this)
                }


                if (selfsx.z种类 != 4 && othersx.z种类 == selfsx.z种类 && othersx.d大小 == 1 && selfsx.d大小 == 1 && Math.abs(othersx.s数值 - selfsx.s数值) == 1) {   //两小合成吃
                    this.k可碰撞 = false
                    let sen = self.node
                    let otn = other.node

                    self.off(Contact2DType.BEGIN_CONTACT, this.碰撞执行, this)
                    other.off(Contact2DType.BEGIN_CONTACT, this.碰撞执行, this)

                    let sv = sen.worldPosition
                    let ov = otn.worldPosition
                    let v = v3((sv.x + ov.x) / 2, (sv.y + ov.y) / 2, 0)

                    let ang = this.ty.j夹角计算(sv, ov)
                    this.s生成合成麻将(selfsx, v, ang, othersx.s数值)
                    this.s节点数组.splice(this.s节点数组.indexOf(otn), 1)
                    this.s节点数组.splice(this.s节点数组.indexOf(sen), 1)
                    director.once(Director.EVENT_AFTER_PHYSICS, () => {    //EVENT_AFTER_PHYSICS为物理碰撞完成后执行的事件
                        otn.destroy()
                        sen.destroy()
                        this.k可碰撞 = true
                    }, this)
                }


                if (othersx.s数值 == selfsx.s数值 && othersx.z种类 == selfsx.z种类 && othersx.d大小 + selfsx.d大小 == 3 && selfsx.c吃 == 0 && othersx.c吃 == 0) {   //碰
                    this.k可碰撞 = false
                    self.off(Contact2DType.BEGIN_CONTACT, this.碰撞执行, this)
                    other.off(Contact2DType.BEGIN_CONTACT, this.碰撞执行, this)

                    director.once(Director.EVENT_AFTER_PHYSICS, () => {    //EVENT_AFTER_PHYSICS为物理碰撞完成后执行的事件
                        let sen = self.node
                        let otn = other.node
                        self.getComponent(RigidBody2D).enabled = false
                        other.getComponent(RigidBody2D).enabled = false

                        this.ty.X修改子节点位置(sen, 1)
                        this.ty.X修改子节点位置(otn, 1)
                        this.s节点数组.splice(this.s节点数组.indexOf(otn), 1)
                        this.s节点数组.splice(this.s节点数组.indexOf(sen), 1)
                        let collider = sen.getComponent(Collider2D);
                        collider.enabled = false
                        let collider2 = otn.getComponent(Collider2D);
                        collider2.enabled = false

                        tween(sen).to(0.1, { angle: 0 }).to(0.3, { position: v3(-120, -145, 0) }).start()
                        tween(otn).to(0.1, { angle: 0 }).to(0.3, { position: v3(106, -145, 0) })
                            .call(() => {
                                tween(sen).to(0.2, { position: v3(-60, -145, 0) }).start()
                                tween(otn).to(0.2, { position: v3(46, -145, 0) })
                                    .call(() => {
                                        this.p碰动画()
                                    })
                                    .delay(0.5)
                                    .call(() => {
                                        otn.destroy()
                                        sen.destroy()
                                        this.k可碰撞 = true
                                    })
                                    .start()
                            })
                            .start()
                    }, this)
                }

                if (othersx.z种类 == selfsx.z种类) {     //吃
                    if ((selfsx.c吃 == 0 && othersx.c吃 != 0) || (selfsx.c吃 != 0 && othersx.c吃 == 0)) {
                        if (selfsx.s数值 != othersx.s数值 && selfsx.s数值 != othersx.c吃 && selfsx.d大小 + othersx.d大小 == 3) {
                            let tj = false
                            if (selfsx.c吃 == 0) {
                                if (selfsx.s数值 == othersx.s数值 - 1 || selfsx.s数值 == othersx.c吃 + 1) {
                                    tj = true
                                }

                            }
                            if (othersx.c吃 == 0) {
                                if (othersx.s数值 == selfsx.s数值 - 1 || othersx.s数值 == selfsx.c吃 + 1) {
                                    tj = true
                                }
                            }

                            if (tj) {
                                this.k可碰撞 = false
                                self.off(Contact2DType.BEGIN_CONTACT, this.碰撞执行, this)
                                other.off(Contact2DType.BEGIN_CONTACT, this.碰撞执行, this)

                                director.once(Director.EVENT_AFTER_PHYSICS, () => {    //EVENT_AFTER_PHYSICS为物理碰撞完成后执行的事件

                                    let sen = self.node
                                    let otn = other.node
                                    self.getComponent(RigidBody2D).enabled = false
                                    other.getComponent(RigidBody2D).enabled = false

                                    this.ty.X修改子节点位置(sen, 1)
                                    this.ty.X修改子节点位置(otn, 1)
                                    this.s节点数组.splice(this.s节点数组.indexOf(otn), 1)
                                    this.s节点数组.splice(this.s节点数组.indexOf(sen), 1)
                                    let collider = sen.getComponent(Collider2D);
                                    collider.enabled = false
                                    let collider2 = otn.getComponent(Collider2D);
                                    collider2.enabled = false

                                    tween(sen).to(0.1, { angle: 0 }).to(0.3, { position: v3(-130, -145, 0) }).start()
                                    tween(otn).to(0.1, { angle: 0 }).to(0.3, { position: v3(130, -145, 0) })
                                        .call(() => {
                                            tween(sen).to(0.2, { position: v3(-70, -145, 0) }).start()
                                            tween(otn).to(0.2, { position: v3(70, -145, 0) })
                                                .call(() => {
                                                    otn.destroy()
                                                    sen.destroy()
                                                    this.k可碰撞 = true
                                                    this.c吃动画()
                                                })
                                                .start()
                                        })
                                        .start()
                                }, this)


                            }
                        }
                    }
                }


                if (othersx.s数值 == selfsx.s数值 && othersx.z种类 == selfsx.z种类 && othersx.d大小 + selfsx.d大小 == 4 && othersx.c吃 == 0 && selfsx.c吃 == 0) {   //杠
                    this.k可碰撞 = false
                    self.off(Contact2DType.BEGIN_CONTACT, this.碰撞执行, this)
                    other.off(Contact2DType.BEGIN_CONTACT, this.碰撞执行, this)

                    director.once(Director.EVENT_AFTER_PHYSICS, () => {    //EVENT_AFTER_PHYSICS为物理碰撞完成后执行的事件
                        let sen = self.node
                        let otn = other.node

                        self.getComponent(RigidBody2D).enabled = false
                        other.getComponent(RigidBody2D).enabled = false
                        let collider = self.node.getComponent(Collider2D);
                        collider.enabled = false
                        let collider2 = other.node.getComponent(Collider2D);
                        collider2.enabled = false

                        this.ty.X修改子节点位置(sen, 1)
                        this.ty.X修改子节点位置(otn, 1)
                        this.s节点数组.splice(this.s节点数组.indexOf(otn), 1)
                        this.s节点数组.splice(this.s节点数组.indexOf(sen), 1)


                        tween(sen).to(0.1, { angle: 0 }).to(0.3, { position: v3(-130, -145, 0) }).start()
                        tween(otn).to(0.1, { angle: 0 }).to(0.3, { position: v3(130, -145, 0) })
                            .call(() => {
                                tween(sen).to(0.2, { position: v3(-70, -145, 0) }).start()
                                tween(otn).to(0.2, { position: v3(70, -145, 0) })
                                    .call(() => {
                                        otn.destroy()
                                        sen.destroy()
                                        this.k可碰撞 = true
                                        this.g杠动画()
                                    })
                                    .start()
                            })
                            .start()
                    }, this)
                }




            }

        }
    }

    s碰撞生成检测(self: Collider2D, other: Collider2D,) {
        if (other.node.getComponent(BoxCollider2D).tag == -3 || self.node.getComponent(BoxCollider2D).tag) {

        } else {
            director.once(Director.EVENT_AFTER_PHYSICS, () => {
                if (this.d当前麻将.position.y > 356) {
                    this.s满格失败执行()
                }

                if (this.d当前麻将.position.y > 180) {
                    this.j警告线()
                }

                this.ty.bofangshenyin(28)
                this.K可点击 = true
                let rig = this.d当前麻将.getComponent(RigidBody2D)
                rig.gravityScale = this.z正常重力
                this.s生成新的麻将()
            }, this)
        }

    }

    q圈动画() {
        let n1 = this.ty.find查找('Canvas/主程序/动画组/圈/dongquan1')
        let n2 = this.ty.find查找('Canvas/主程序/动画组/圈/dongquan2')
        n1.setPosition(0, 0)
        n2.setPosition(0, 0)
        n2.angle = -250
        tween(n2).to(0.3, { angle: 0 })
            .call(() => {
                n1.setPosition(0, 5000)
                n2.setPosition(0, 5000)
            })
            .start()
    }

    p碰动画() {
        this.ty.bofangshenyin(29)
        let n = find('Canvas/主程序/动画组/碰')
        n.setPosition(0, 260)
        n.setScale(0.5, 0.5)
        Tween.stopAllByTarget(n)
        tween(n).to(0.2, { position: v3(0, 0) }).start()
        tween(n).to(0.2, { scale: v3(1, 1) })
            .call(() => {
                let zi = find('Canvas/主程序/动画组/星星飞舞')
                zi.setPosition(0, 0)
                this.ty.b播放粒子(zi)
                this.q圈动画()
            })
            .delay(1)
            .set({ position: v3(2000, 0) })
            .start()

        let f = () => {
            this.d得分动画(this.b变动SJ.p碰得分)
        }
        this.scheduleOnce(f, 0.4)
        this.l连击执行()
    }

    g杠动画() {
        this.ty.bofangshenyin(30)
        let n = find('Canvas/主程序/动画组/杠')
        n.setPosition(0, 260)
        n.setScale(0.5, 0.5, 1)
        Tween.stopAllByTarget(n)
        tween(n).to(0.2, { position: v3(0, 0) }).start()
        tween(n).to(0.2, { scale: v3(1, 1, 1) })
            .call(() => {
                let zi = find('Canvas/主程序/动画组/星星飞舞')
                zi.setPosition(0, 0)
                this.ty.b播放粒子(zi)
                this.q圈动画()
            })
            .delay(1)
            .set({ position: v3(2000, 0) })
            .start()

        let f = () => {
            this.d得分动画(this.b变动SJ.g杠得分)
        }
        this.scheduleOnce(f, 0.4)
        this.l连击执行()
    }

    c吃动画() {
        this.ty.bofangshenyin(31)
        let n = find('Canvas/主程序/动画组/吃')
        n.setPosition(0, 260)
        n.setScale(0.5, 0.5, 1)
        Tween.stopAllByTarget(n)
        tween(n).to(0.2, { position: v3(0, 0) }).start()
        tween(n).to(0.2, { scale: v3(1, 1, 1) })
            .call(() => {
                let zi = find('Canvas/主程序/动画组/星星飞舞')
                zi.setPosition(0, 0)
                this.ty.b播放粒子(zi)
                this.q圈动画()
            })
            .delay(1)
            .set({ position: v3(2000, 0) })
            .start()

        let f = () => {
            this.d得分动画(this.b变动SJ.c得分)
        }
        this.scheduleOnce(f, 0.4)
        this.l连击执行()
    }


    d得分动画(d得分: number) {
        this.ty.z震动执行()
        let n = find('Canvas/主程序/动画组/飞动星')
        Tween.stopAllByTarget(n)
        n.setPosition(0, -160)

        let pv = find('Canvas/主程序/上方显示组/积分模式/得分显示/xingxing').worldPosition

        tween(n)
            .to(1.3, { worldPosition: v3(pv) }, { easing: 'quintIn' })
            .set({ position: v3(0, 5000) })
            .start()


        this.d当前得分 += d得分
        this.d当前进度++
        this.g更新进度显示()
        this.g更新得分显示()

    }

    l连击执行() {
        this.l连击次数++
        let n = find('Canvas/主程序/动画组/联机组')

        Tween.stopAllByTarget(n)
        tween(n).delay(this.b变动SJ.l连击时间)
            .call(() => {
                this.l连击次数 = 0
            })
            .start()

        if (this.l连击次数 > 1) {
            this.ty.bofangshenyin(5)
            n.setPosition(-253, 292)
            let wzn = find('Canvas/主程序/动画组/联机组/Label')
            let wz = '连击 X' + this.l连击次数
            this.ty.x修改文字(wzn, wz)

            let jdt = find('Canvas/主程序/动画组/联机组/hengyuan/baikuai')
            jdt.setPosition(0, 0)
            Tween.stopAllByTarget(jdt)
            tween(jdt).by(this.b变动SJ.l连击时间, { position: v3(-150, 0) })
                .call(() => {
                    n.setPosition(2000, 0)
                })
                .start()


            let xn = find('Canvas/主程序/动画组/联机组/星')
            Tween.stopAllByTarget(xn)
            xn.setPosition(95, 0)
            tween(xn)
                .by(0.8, { position: v3(0, 30) })
                .set({ position: v3(0, 5000) })
                .start()

            this.d当前得分 += this.b变动SJ.l连击奖励
            this.g更新进度显示()

        }
    }


    doudongZXZ = []
    d抖一抖执行() {
        this.ty.z震动执行()
        let n = find('Canvas/主程序/碰撞主/墙')
        let fu = 50
        let shijian = 1
        if (this.doudongZXZ.indexOf(n) == -1) {
            this.ty.bofangshenyin(16)
            let cd = this.s节点数组.length
            let zsj = 1
            let sj = zsj / cd
            let daihao = -1
            this.s节点数组.forEach((e) => {
                daihao++
                if (e != this.d当前麻将) {
                    let wl = e.getComponent(RigidBody2D)
                    wl.wakeUp()
                    if (e.getComponent(RigidBody2D)) {
                        tween(e).delay((cd + 1 - daihao) * sj).call(() => {
                            wl.gravityScale = -this.z正常重力
                            tween(e).delay(0.5).call(() => {
                                wl.gravityScale = this.z正常重力
                            }).start()
                        }).start()

                    }
                }
            })

            this.doudongZXZ.push(n)
            tween(n)
                .by(shijian / 8, { position: new Vec3(fu, fu, 0) })
                .by(shijian / 8, { position: new Vec3(- fu, - fu, 0) })
                .by(shijian / 8, { position: new Vec3(-fu, fu, 0) })
                .by(shijian / 8, { position: new Vec3(fu, - fu, 0) })
                .by(shijian / 8, { position: new Vec3(-fu, -fu, 0) })
                .by(shijian / 8, { position: new Vec3(fu, fu, 0) })
                .by(shijian / 8, { position: new Vec3(fu, -fu, 0) })
                .by(shijian / 8, { position: new Vec3(-fu, fu, 0) })
                .call(() => {
                    let dhs = this.doudongZXZ.indexOf(n)
                    this.doudongZXZ.splice(dhs, 1)
                })
                .start()
        }
    }

    //刷新
    s刷新执行() {
        let n = this.d当前麻将
        let nam: s属性 = JSON.parse(n.name)
        n.children[0].children[nam.z种类 - 1].children[nam.s数值 - 1].active = false
        let shuzhi = 1
        let zhonglei = 1
        zhonglei = this.ty.Rand(1, this.b变动SJ.z种类最大数)
        if (zhonglei == 4) {
            shuzhi = this.ty.Rand(1, 7)
        } else {
            shuzhi = this.ty.Rand(1, this.b变动SJ.s数值最大数)
        }

        let a: s属性 = {
            z种类: zhonglei,
            s数值: shuzhi,
            d大小: 1,
            c吃: 0
        }

        n.name = JSON.stringify(a)
        n.children[0].children[zhonglei - 1].children[shuzhi - 1].active = true

        tween(n)
            .call(() => { this.K可点击 = false })
            .to(0.2, { scale: v3(-1, 1, 1) })
            .to(0.2, { scale: v3(1, 1, 1) })
            .call(() => { this.K可点击 = true })
            .start()

    }

    //消除
    x消除执行() {
        this.ty.z震动执行()
        let a: Node[] = []
        this.s节点数组.forEach((n: Node) => {
            a.push(n)
        })

        let leixing = this.ty.Rand(1, this.b变动SJ.z种类最大数)

        a.forEach((n: Node) => {
            if (n != this.d当前麻将) {
                let nam: s属性 = JSON.parse(n.name)
                if (nam.z种类 == leixing) {
                    this.s节点数组.splice(this.s节点数组.indexOf(n), 1)
                    n.destroy()
                }
            }
        })

    }

    //炸弹
    z炸弹执行() {
        this.ty.z震动执行()
        this.ty.bofangshenyin(11)
        //爆炸动画
        let n = find('Canvas/主程序/动画组/爆炸')
        n.getComponent(Animation).play()

        let a: Node[] = []
        this.s节点数组.forEach((n: Node) => {
            a.push(n)
        })

        a.forEach((n: Node) => {
            if (n != this.d当前麻将) {
                let v1 = v3(0, 0, 0)
                let jili = this.ty.p判断距离(v1, n.position, this.z炸弹距离)
                if (jili) {
                    this.s节点数组.splice(this.s节点数组.indexOf(n), 1)
                    n.destroy()
                }

            }
        })

    }



    //UI
    设置点击() {
        this.ty.c创建banner(2)
        this.z没暂停 = false
        this.ty.bofangshenyin(1)
        let n = find('Canvas/弹出主/设置弹出')
        this.ty.t弹出通用(n)
    }

    设置关闭() {
        this.ty.g关闭banner()
        this.z没暂停 = true
        this.ty.bofangshenyin(1)
        let n = find('Canvas/弹出主/设置弹出')
        this.ty.g关闭通用(n)
    }

    t退出() {
        this.ty.g关闭banner()
        this.ty.bofangshenyin(1)
        if (SJTS.j进入模式 == 1) {
            if (this.d当前得分 > this.HC_XLMJ_zuigaofen) {
                localStorage.setItem('HC_XLMJ_zuigaofen', JSON.stringify(this.d当前得分))
            }
        }
        this.ty.c创建插屏()
        Tween.stopAll()
        director.loadScene('kaishichangjing')
    }


    //道具点击
    c初次刷新 = 1
    刷新点击() {
        if (this.K可点击) {
            if (this.c初次刷新 == 1) {
                let fsx = () => {
                    this.c初次刷新 = 0
                    this.s刷新数 += 5
                    this.s刷新执行()
                    this.d道具显示更新(1)
                }
                this.ty.f分享(fsx)
            } else {
                if (this.s刷新数 > 0) {
                    this.ty.bofangshenyin(1)
                    this.s刷新数 -= 1
                    this.s刷新执行()
                    this.d道具显示更新(1)
                } else {
                    this.ty.bofangshenyin(4)
                    let n = find('Canvas/主程序/下方显示组/道具组/道具_刷新/数量')
                    this.ty.d抖动(n)
                }
            }


        }
    }

    关闭提示() {
        this.ty.bofangshenyin(1)
        let n = find('Canvas/弹出主/提示')
        this.ty.g关闭通用(n)
    }

    消除点击() {
        if (this.K可点击) {
            if (this.x消除数 > 0) {
                this.ty.bofangshenyin(1)
                this.x消除数 -= 1
                this.x消除执行()
                this.d道具显示更新(2)
            } else {
                this.ty.bofangshenyin(4)
                let ntbz = find('Canvas/弹出主/提示/小组/图标组').children
                ntbz.forEach((n) => {
                    this.ty.x修改透明度(n, 0)
                })
                let ntb = find('Canvas/弹出主/提示/小组/图标组/图标消除')
                this.ty.x修改透明度(ntb, 255)

                let wzn = find('Canvas/弹出主/提示/小组/提示文字')
                let wz = "观看完整视频\n免费获得道具消除"
                this.ty.x修改文字(wzn, wz)

                let nlq = find('Canvas/弹出主/提示/小组/领取组').children
                nlq.forEach((n) => {
                    n.setPosition(0, 5000)
                })
                nlq[0].setPosition(140, -200)

                let n = find('Canvas/弹出主/提示')
                this.ty.t弹出通用(n)
                if (SJTS.z直接播放) {
                    this.消除广告完成()
                }

            }
        }
    }

    炸弹点击() {
        if (this.K可点击) {
            if (this.z炸弹数 > 0) {
                this.z炸弹数 -= 1
                this.z炸弹执行()
                this.d道具显示更新(3)
            } else {
                this.ty.bofangshenyin(1)
                let ntbz = find('Canvas/弹出主/提示/小组/图标组').children
                ntbz.forEach((n) => {
                    this.ty.x修改透明度(n, 0)
                })
                let ntb = find('Canvas/弹出主/提示/小组/图标组/图标炸弹')
                this.ty.x修改透明度(ntb, 255)

                let wzn = find('Canvas/弹出主/提示/小组/提示文字')
                let wz = "观看完整视频\n免费获得道具炸弹"
                this.ty.x修改文字(wzn, wz)

                let nlq = find('Canvas/弹出主/提示/小组/领取组').children
                nlq.forEach((n) => {
                    n.setPosition(0, 5000)
                })
                nlq[1].setPosition(140, -200)

                let n = find('Canvas/弹出主/提示')
                this.ty.t弹出通用(n)

                if (SJTS.z直接播放) {
                    this.炸弹广告完成()
                }

            }
        }
    }

    抖动点击() {
        if (this.K可点击) {
            if (this.d抖动数 > 0) {
                if (this.doudongZXZ.length == 0) {
                    this.d抖动数 -= 1
                    this.d道具显示更新(4)
                    if (SJTS.j进入模式 == 1) {
                        localStorage.setItem('HC_doudongshu', JSON.stringify(this.d抖动数))
                    }
                    this.d抖一抖执行()
                }
            } else {
                this.ty.bofangshenyin(4)
                let ntbz = find('Canvas/弹出主/提示/小组/图标组').children
                ntbz.forEach((n) => {
                    this.ty.x修改透明度(n, 0)
                })
                let ntb = find('Canvas/弹出主/提示/小组/图标组/图标抖一抖')
                this.ty.x修改透明度(ntb, 255)

                let wzn = find('Canvas/弹出主/提示/小组/提示文字')
                let wz = "观看完整视频\n永久获得道具抖一抖"
                this.ty.x修改文字(wzn, wz)

                let nlq = find('Canvas/弹出主/提示/小组/领取组').children
                nlq.forEach((n) => {
                    n.setPosition(0, 5000)
                })
                nlq[2].setPosition(140, -200)

                let n = find('Canvas/弹出主/提示')
                this.ty.t弹出通用(n)
                if (SJTS.z直接播放) {
                    this.抖动广告完成()
                }
            }
        }
    }

    消除广告完成() {
        let f = () => {
            let n = find('Canvas/弹出主/提示')
            this.ty.g关闭通用(n)
            this.x消除数 += this.g广告领取消除数
            this.d道具显示更新(2)
        }
        this.ty.c创建激励广告(f)

    }

    炸弹广告完成() {
        let f = () => {
            let n = find('Canvas/弹出主/提示')
            this.ty.g关闭通用(n)
            this.z炸弹数 += this.g广告领取炸弹数
            this.d道具显示更新(3)
        }
        this.ty.c创建激励广告(f)

    }

    抖动广告完成() {
        let f = () => {
            let n = find('Canvas/弹出主/提示')
            this.ty.g关闭通用(n)
            this.d抖动数 += this.g广告领取抖动数
            localStorage.setItem('HC_doudongshu', JSON.stringify(this.d抖动数))
            this.d道具显示更新(4)
        }
        this.ty.c创建激励广告(f)

    }


}